#include "anf.h"
#include "ui_anf.h"
#include"QPainter"
#include "qsettings.h"
#include "HRVPro/hrvdataprocess.h"
#include "Config/constant.h"

Anf::Anf(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Anf)
{
    ui->setupUi(this);
    ui->progressBar_Activity_report->setTextVisible(false);
    ui->progressBar_Ballance_report->setTextVisible(false);
    ui->progressBar_BodyPressure_report->setTextVisible(false);
    ui->progressBar_PrePressure_report->setTextVisible(false);
    ui->progressBar_Emotion_report->setTextVisible(false);
    ui->progressBar_Fatigure_report->setTextVisible(false);
    ui->progressBar_MentalPressure_report->setTextVisible(false);
    ui->progressBar_Heart_report->setTextVisible(false);
    QSettings setting("./Configuration.ini",QSettings::IniFormat);
    setting.beginGroup("Config");
    QString reportName=setting.value("ReportName").toString();
    setting.endGroup();
    ui->label_Mental_Title->setText(reportName+"（自主神经功能）分析报告");
}

Anf::~Anf()
{
    delete ui;
}
void Anf::setValue(DataBeans dataBean)
{
    QSettings *setting=new QSettings("./Configuration.ini",QSettings::IniFormat);
    setting->beginGroup("Config");
    QString JGName=setting->value("User").toString();
    setting->endGroup();
    delete setting;
    HRVDataProcess hrvdataPro;
    HRVIndex hi=hrvdataPro.Json2HRVData(dataBean.hrvIndexResults);
    ui->label_DW->setText(JGName);
    ui->label_display_ID->setText(dataBean.UserID);
    ui->label_display_name->setText(dataBean.UserName);
    ui->label_display_age->setText(dataBean.UserAge+"/"+dataBean.UserSex);
    ui->label_display_time->setText(dataBean.MeasureTime);

    ui->label_4_BodyPressureNameV->setText(QString::number(hi.mp.PsiScore,'f',1));
    ui->progressBar_BodyPressure_report->setValue(hi.mp.PsiScore);

    ui->label_4_MentalPressureNameV->setText(QString::number(hi.mp.MsiScore,'f',1));
    ui->progressBar_MentalPressure_report->setValue(hi.mp.MsiScore);

    ui->label_4_PrePressureNameV->setText(QString::number(hi.mp.SdnnScore,'f',1));
    ui->progressBar_PrePressure_report->setValue(hi.mp.SdnnScore);

    ui->label_4_FatigureNameV->setText(QString::number(hi.mp.lfScore,'f',1));
    ui->progressBar_Fatigure_report->setValue(hi.mp.lfScore);

    ui->label_4_ActivityNameV->setText(QString::number(hi.mp.tpScore,'f',1));
    ui->progressBar_Activity_report->setValue(hi.mp.tpScore);

    ui->label_4_BallanceNameV->setText(QString::number(hi.mp.AnsScore,'f',1));
    ui->progressBar_Ballance_report->setValue(hi.mp.AnsScore);

    ui->label_4_HeartNameV->setText(QString::number(hi.mp.hfScore,'f',1));
    ui->progressBar_Heart_report->setValue(hi.mp.hfScore);

    ui->label_4_EmotionNameV->setText(QString::number(hi.mp.EmotionScore,'f',1));
    ui->progressBar_Emotion_report->setValue(hi.mp.EmotionScore);
    ui->textEdit_MentalRes->setText(hi.MentalPressureResults+"\n"+hi.AnsResults);
    ui->label_PressureScoreV_report->setText(QString::number(hi.mp.TotalScore,'f',1));


}
